<!DOCTYPE html>

<html lang="en">
<head>
	<meta charset="utf-8">
	<title>ScrollMagic Documentation</title>
	
  <script src="scripts/prettify/prettify.js"> </script>
  <script src="scripts/prettify/lang-css.js"> </script>
	<!--[if lt IE 9]>
	<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
	<![endif]-->
	<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
	<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
	<link rel="shortcut icon" href="../assets/img/favicon.ico" type="image/x-icon">

	
	<link type="text/css" rel="stylesheet" href="styles/site.cosmo.css">
	
</head>

<body>
<div class="container-fluid">
	<div class="navbar navbar-fixed-top navbar-inverse">
		<div class="navbar-inner">
			<a class="brand" href="index.html">ScrollMagic</a>
			<ul class="nav">
				
				<li class="dropdown">
					<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
						class="caret"></b></a>

					<ul class="dropdown-menu ">
						
						<li>
							<a href="ScrollMagic.Controller.html">Controller</a>
						</li>
						
						<li>
							<a href="ScrollMagic.Scene.html">Scene</a>
						</li>
						

					</ul>
				</li>
				
				<li class="dropdown">
					<a href="events.list.html" class="dropdown-toggle" data-toggle="dropdown">Events<b
						class="caret"></b></a>

					<ul class="dropdown-menu ">
						
						<li>
							<a href="ScrollMagic.Scene.html#event:add">add</a>
						</li>
						
						<li>
							<a href="ScrollMagic.Scene.html#event:change">change</a>
						</li>
						
						<li>
							<a href="ScrollMagic.Scene.html#event:destroy">destroy</a>
						</li>
						
						<li>
							<a href="ScrollMagic.Scene.html#event:end">end</a>
						</li>
						
						<li>
							<a href="ScrollMagic.Scene.html#event:enter">enter</a>
						</li>
						
						<li>
							<a href="ScrollMagic.Scene.html#event:leave">leave</a>
						</li>
						
						<li>
							<a href="ScrollMagic.Scene.html#event:progress">progress</a>
						</li>
						
						<li>
							<a href="ScrollMagic.Scene.html#event:remove">remove</a>
						</li>
						
						<li>
							<a href="ScrollMagic.Scene.html#event:shift">shift</a>
						</li>
						
						<li>
							<a href="ScrollMagic.Scene.html#event:start">start</a>
						</li>
						
						<li>
							<a href="ScrollMagic.Scene.html#event:update">update</a>
						</li>
						

					</ul>
				</li>
				
				<li class="dropdown">
					<a href="mixins.list.html" class="dropdown-toggle" data-toggle="dropdown">Plugins<b
						class="caret"></b></a>

					<ul class="dropdown-menu ">
						
						<li>
							<a href="animation.GSAP.html">GSAP</a>
						</li>
						
						<li>
							<a href="animation.Velocity.html">Velocity</a>
						</li>
						
						<li>
							<a href="debug.addIndicators.html">addIndicators</a>
						</li>
						
						<li>
							<a href="framework.jQuery.html">jQuery</a>
						</li>
						

					</ul>
				</li>
				
			</ul>
		</div>
	</div>

	<div class="row-fluid">

		
		<div class="span8">
			
				<div id="main">
					


	
	<span class="page-title">Documentation</span>
	
	












	
	





    <section>
        <article><h1 id="scrollmagic-a-href-https-github-com-janpaepke-scrollmagic-blob-master-changelog-md-class-version-title-whats-new-v2-0-7-a-build-status">ScrollMagic <a href='https://github.com/janpaepke/ScrollMagic/blob/master/CHANGELOG.md' class='version' title='Whats New?'>v2.0.7</a> <a href="https://travis-ci.org/janpaepke/ScrollMagic"><img src="https://api.travis-ci.org/janpaepke/ScrollMagic.svg?branch=master" alt="Build Status"></a></h1>
<h3 id="the-javascript-library-for-magical-scroll-interactions-">The javascript library for magical scroll interactions.</h3>
<p><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=8BJC8B58XHKLL" title="Shut up and take my money!"><img src="https://scrollmagic.io/assets/img/btn_donate.svg" alt="Donate" title="Shut up and take my money!"></a> <a href="https://nerdpool.io/support/scrollmagic?utm_source=github&utm_medium=btn" title="Get personal live support"><img src="https://cdn.nerdpool.io/np-btn-support-blue.png" style="height: 40px" height="40" alt="Request personal live support"></a></p>
<p><strong>Quicklinks:</strong> <a href="#about-the-library">About</a> | <a href="#availability">Download</a> | <a href="#installation">Installation</a> | <a href="#usage">Usage</a> | <a href="#help">Help</a> | <a href="#browser-support">Compatibility</a> | <a href="#about-the-author">Author</a> | <a href="#license">License</a> | <a href="#thanks">Thanks</a></p>
<hr>
<p>ScrollMagic helps you to easily react to the user's current scroll position.<br>It's the perfect library for you, if you want to ...</p>
<ul>
<li>animate based on scroll position – either trigger an animation or synchronize it to the scrollbar movement (like a playback scrub control).</li>
<li>pin an element starting at a specific scroll position – either indefinitely or for a limited amount of scroll progress (sticky elements).</li>
<li>toggle CSS classes of elements on and off based on scroll position.</li>
<li>effortlessly add parallax effects to your website.</li>
<li>create an infinitely scrolling page (ajax load of additional content).</li>
<li>add callbacks at specific scroll positions or while scrolling past a specific section, passing a progress parameter.</li>
</ul>
<p>Check out <a href="http://scrollmagic.io">the demo page</a>, browse <a href="http://scrollmagic.io/examples/index.html">the examples</a> or read <a href="http://scrollmagic.io/docs/index.html">the documentation</a> to get started.<br>If you want to contribute please <a href="mailto:e-mail@janpaepke.de">get in touch</a> and let me know about your specialty and experience.</p>
<h2 id="about-the-library">About the Library</h2>
<p>ScrollMagic is a scroll interaction library.</p>
<p>It's a complete rewrite of its predecessor <a href="https://github.com/johnpolacek/superscrollorama">Superscrollorama</a> by <a href="http://johnpolacek.com">John Polacek</a>.<br>A plugin-based architecture offers easy customizability and extendability.</p>
<p>To implement animations, ScrollMagic can work with multiple frameworks.<br>The recommended solution is the <a href="http://www.greensock.com/gsap-js/">Greensock Animation Platform (GSAP)</a> due to its stability and feature richness. For a more lightweight approach the <a href="http://VelocityJS.org">VelocityJS</a> framework is also supported. Alternatively custom extensions can be implemented or the necessity of a framework can be completely avoided by animating simply using CSS and class toggles.</p>
<p>ScrollMagic was developed with these principles in mind:</p>
<ul>
<li>optimized performance</li>
<li>lightweight (6KB gzipped)</li>
<li>flexibility and extendibility</li>
<li>mobile compatibility</li>
<li>event management</li>
<li>support for responsive web design</li>
<li>object oriented programming and object chaining</li>
<li>readable, centralized code and intuitive development</li>
<li>support for both x and y direction scrolling (even both on one page)</li>
<li>support for scrolling inside div containers (even multiple on one page)</li>
<li>extensive debugging and logging capabilities</li>
<li>detailed documentation</li>
<li>many application examples</li>
</ul>
<p><strong>Is ScrollMagic the right library for you?</strong><br>ScrollMagic takes an object oriented approach using a controller for each scroll container and attaching multiple scenes defining what should happen at what part of the page. While this offers a great deal of control, it might be a little confusing, especially if you're just starting out with javascript.<br>If the above points are not crucial for you and you are just looking for a simple solution to implement css animations I would strongly recommend taking a look at the awesome <a href="http://prinzhorn.github.io/skrollr/">skrollr</a> project. It almost solely relies on element attributes and thus requires minimal to no javascript knowledge.</p>
<h2 id="availability">Availability</h2>
<p>To get your copy of ScrollMagic you have the choice between four options:</p>
<p><strong>Option 1: GitHub</strong><br>Download a zip file containing the source code, demo page, all examples and documentation from the <a href="https://github.com/janpaepke/ScrollMagic/releases">GitHub releases page</a> or clone the package to your machine using the git command line interface:</p>
<pre class="prettyprint source lang-bash"><code>git clone git://github.com/janpaepke/ScrollMagic.git</code></pre><p><strong>Option 2: Bower</strong><br>ScrollMagic is also <a href="http://bower.io/search/?q=scrollmagic">available on bower</a> and will only install the necessary source code, ignoring all example and documentation files.<br>Please mind that since they are not core dependencies, you will have to add frameworks like GSAP, jQuery or Velocity manually, should you choose to use them.</p>
<pre class="prettyprint source lang-bash"><code>bower install scrollmagic</code></pre><p><strong>Option 3: npm</strong><br>If you prefer the <a href="https://www.npmjs.com/package/scrollmagic">node package manager</a>, feel free to use it.<br>Keep in mind that like with bower non-crucial files will be ignored (see above).</p>
<pre class="prettyprint source lang-bash"><code>npm install scrollmagic</code></pre><p><strong>Option 4: CDN</strong><br>If you don't want to host ScrollMagic yourself, you can include it from <a href="https://cdnjs.com/libraries/ScrollMagic">cdnjs</a>:</p>
<pre class="prettyprint source"><code>http://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/ScrollMagic.min.js</code></pre><p>All plugins and uncompressed files are also available on cdnjs.<br>For example:</p>
<pre class="prettyprint source"><code>http://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/plugins/debug.addIndicators.js
http://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/plugins/debug.addIndicators.min.js</code></pre><h2 id="installation">Installation</h2>
<p>Include the <strong>core</strong> library in your HTML file:</p>
<pre class="prettyprint source lang-html"><code>&lt;script src=&quot;js/scrollmagic/uncompressed/ScrollMagic.js&quot;>&lt;/script></code></pre><p>And you're ready to go!<br>For deployment use the minified version <strong>instead</strong>:</p>
<pre class="prettyprint source lang-html"><code>&lt;script src=&quot;js/scrollmagic/minified/ScrollMagic.min.js&quot;>&lt;/script></code></pre><p><em><strong>NOTE:</strong> The logging feature is removed in the minified version due to file size considerations.</em></p>
<p>To use <strong>plugins</strong> like the indicators visualization, simply include them additionally to the main library:</p>
<pre class="prettyprint source lang-html"><code>&lt;script src=&quot;js/scrollmagic/uncompressed/plugins/debug.addIndicators.js&quot;>&lt;/script></code></pre><p>To learn how to configure <strong>RequireJS</strong>, when using AMD, please <a href="https://github.com/janpaepke/ScrollMagic/wiki/Getting-Started-:-Using-AMD">read here</a>.</p>
<h2 id="usage">Usage</h2>
<p>The basic ScrollMagic design pattern is one controller, which has one or more scenes attached to it.<br>Each scene is used to define what happens when the container is scrolled to a specific offset.</p>
<p>Here's a basic workflow example:</p>
<pre class="prettyprint source lang-javascript"><code>// init controller
var controller = new ScrollMagic.Controller();

// create a scene
new ScrollMagic.Scene({
    duration: 100, // the scene should last for a scroll distance of 100px
    offset: 50 // start this scene after scrolling for 50px
})
    .setPin('#my-sticky-element') // pins the element for the the scene's duration
    .addTo(controller); // assign the scene to the controller</code></pre><p>To learn more about the ScrollMagic code structure, please <a href="https://github.com/janpaepke/ScrollMagic/wiki/Getting-Started-:-How-to-use-ScrollMagic">read here</a>.</p>
<h2 id="help">Help</h2>
<p>To get started, check out the available learning resources <a href="https://github.com/janpaepke/ScrollMagic/wiki">in the wiki section</a>.<br>Be sure to have a look at the <a href="http://janpaepke.github.com/ScrollMagic/examples/index.html">examples</a> to get source code pointers and make use of the <a href="http://janpaepke.github.com/ScrollMagic/docs/index.html">documentation</a> for a complete reference.</p>
<p>If you run into trouble using ScrollMagic please follow the <a href="https://github.com/janpaepke/ScrollMagic/wiki/Troubleshooting-Guide">Troubleshooting guide</a>.</p>
<p><strong>Please do not post support requests in the github issue section</strong>, as it's reserverd for issue and bug reporting.<br>If all above options for self-help fail, please use <a href="https://stackoverflow.com/questions/tagged/scrollmagic">Stack Overflow</a> or the <a href="https://support.scrollmagic.io/?utm_source=github&amp;utm_medium=link">ScrollMagic Premium Support</a>.</p>
<h2 id="browser-support">Browser Support</h2>
<p>ScrollMagic aims to support all major browsers even in older versions:<br>Firefox 26+, Chrome 30+, Safari 5.1+, Opera 10+, IE 9+</p>
<h2 id="about-the-author">About the Author</h2>
<p>I am a creative coder based in Vienna, Austria.</p>
<p><a href="http://www.janpaepke.de">Learn more on my website</a> or <a href="http://twitter.com/janpaepke">Follow me on Twitter</a></p>
<h2 id="license">License</h2>
<p>ScrollMagic is dual licensed under the MIT license and GPL.<br>For more information click <a href="https://github.com/janpaepke/ScrollMagic/blob/master/LICENSE.md">here</a>.</p>
<h2 id="thanks">Thanks</h2>
<p>This library was made possible by many people who have supported it with passion, donations or advice. Special thanks go out to: <a href="https://github.com/johnpolacek">John Polacek</a>, <a href="https://github.com/greensock">Jack Doyle</a>, <a href="https://github.com/paulirish">Paul Irish</a>, <a href="https://github.com/ncerminara">Nicholas Cerminara</a>, <a href="https://github.com/krnlde">Kai Dorschner</a>, <a href="https://github.com/petr-tichy">Petr Tichy</a> and <a href="https://github.com/grayghostvisuals">Dennis Gaebel</a>.</p></article>
    </section>
    <style type="text/css">
    	h1.page-title {
    		display: none;
    	}
    	header h2 {
    		display: none;
    	}
    	span.page-title {
    		margin-bottom: 20px;
    	}
    </style>







				</div>

				<div class="clearfix"></div>
				<footer>
					
					
		<span class="copyright">
		© Jan Paepke 2015
		</span>
					<br />
					
		<span class="jsdoc-message">
		Documentation generated by <a href="https://github.com/jsdoc3/jsdoc" target="_blank">JSDoc 3.5.5</a>
		using a customized version of the <a href="https://github.com/terryweiss/docstrap" target="_blank">DocStrap template</a>.
		</span>
				</footer>
			</div>

			
			<div class="span3">
				<div id="toc"></div>
			</div>
			
			<br clear="both">
		</div>

	</div>
	<script src="scripts/sunlight.js"></script>
	<script src="scripts/sunlight.javascript.js"></script>
	<script src="scripts/sunlight-plugin.doclinks.js"></script>
	<script src="scripts/sunlight-plugin.linenumbers.js"></script>
	<script src="scripts/sunlight-plugin.menu.js"></script>
	<script src="scripts/jquery.min.js"></script>
	<script src="scripts/jquery.scrollTo.js"></script>
	<script src="scripts/jquery.localScroll.js"></script>
	<script src="scripts/bootstrap-dropdown.js"></script>
	<script src="scripts/toc.js"></script>

	<script> prettyPrint(); </script>
	<script>  Sunlight.highlightAll({lineNumbers:true,  showMenu: true, enableDoclinks :true}); </script>

	<script>
		function openDeeplinkedElement (skipAni) {
			try {
				$("dt h4.member-collapsed").filter(window.location.hash.substring(1).replace(":", "\\:")).trigger("click", skipAni);
			} catch (e) {
				console.warn("ah ah ah! :p");
			}
		}
		$( function () {
			$( "#toc" ).toc( {
			    anchorName  : function(i, heading, prefix) {
					return $(heading).attr("id") || ( prefix + i );
				},
				selectors   : "h1:visible,h2:visible,h3:visible,h4:visible",
				onScrollFinish : openDeeplinkedElement,
				highlightOffset : 10,
				scrollOffset: 60
			} );
			$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
			$( "#main span[id^='toc']" ).addClass( "toc-shim" );

		} );
	</script>

	
	<script>
		$( function () {
			// $('#main').localScroll({
			// 	offset: { top: 56 } //offset by the height of your header (give or take a few px, see what works for you)
			// });
			// workaround for anchors below header...
			window.setTimeout(function () {
				$(document).scrollTop($(document).scrollTop()-60);
			}, 1)
			
			var hash = window.location.hash.substring(1).replace(":", "\\:");
			$( "dt h4.name" ).each( function () {
				var $this = $( this );
				var icon = $( "<i/>" ).addClass( "icon-plus-sign" ).addClass( "pull-right" ).addClass( "icon-white" );
				var dt = $this.parents( "dt" );
				var children = dt.next( "dd" );

				$this.append( icon ).css( {cursor : "pointer"} );
				$this.addClass( "member-collapsed" ).addClass( "member" );
				if (hash != $this.attr("id")) {
					children.hide();
				}
				$this.toggle( function (e, skipAni) {
					var scrollPos = $(document).scrollTop();
					window.location.hash = $(this).attr("id");
					$(document).scrollTop(scrollPos);
					icon.addClass( "icon-minus-sign" ).removeClass( "icon-plus-sign" ).removeClass( "icon-white" );
					$this.addClass( "member-open" ).removeClass( "member-collapsed" );
					children.slideDown(skipAni ? 0 : undefined);
				}, function () {
					icon.addClass( "icon-plus-sign" ).removeClass( "icon-minus-sign" ).addClass( "icon-white" );
					$this.addClass( "member-collapsed" ).removeClass( "member-open" );
					children.slideUp();
				} );
			} );
			// open if deeplinked
			if (hash.length > 0)
				openDeeplinkedElement(true);
		} );
	</script>
	

	<script type="text/javascript" src="../assets/js/tracking.js"></script>
</body>
</html>
